package com.upb.webserver.common.tools.encryption;

import org.apache.commons.lang3.StringUtils;
import org.bouncycastle.util.encoders.Hex;

/**
 *
 */

public class HexUtil {

    /**
     * 以16进制打印字节数组
     *
     * @param bytes  bytes to encode.
     * @return  return hex in lower case.
     */
    public static String byteToHexLower(byte[] bytes) {
        return StringUtils.lowerCase(Hex.toHexString(bytes));
    }

    /**
     * 以16进制打印字节数组
     *
     * @param bytes bytes to encode.
     * @return  return upper case.
     */
    public static String byteToHexUpper(byte[] bytes) {
        return StringUtils.upperCase(Hex.toHexString(bytes));
    }

    /**
     *
     * @param hexString  hex string to decode.
     * @return bytes.
     */
    public static byte[] hexToByteArray(String hexString){
        return Hex.decode(hexString);
    }

}